<template>
	<div class="app-container">
		<BaseTable :columns="columns" :dataList="dataList">
			<template #action="{ row }">
				<el-button type="primary" size="small" plain @click="toDetail(row.problemId)">详情</el-button>
				<el-button
					v-if="userStore.$state.roles.includes('admin') && row.problemStatus == '1'"
					type="primary"
					size="small"
					plain
					@click="toEdit(row.problemId)"
					>处理</el-button
				>
			</template>
		</BaseTable>
	</div>
</template>
<script setup>
import { reactive } from 'vue'
import BaseTable from '@/components/BaseTable'
import { selectProject } from '@/api/project/project'

import useUserStore from '@/store/modules/user'
import { useRoute } from 'vue-router'
const route = useRoute()
const userStore = useUserStore()

const { proxy } = getCurrentInstance()
const { problem_status } = proxy.useDict('problem_status')
const router = useRouter()

const columns = ref([
	{ key: 1, label: `客户名称`, prop: 'customerName', type: 'text', visible: true },
	{ key: 2, width: '150', label: `项目名称`, prop: 'projectName', type: 'text', visible: true },
	{ key: 3, width: '150', label: `合同签订日期`, prop: 'progressFinishTime', type: 'date', visible: true },
	{ key: 4, width: '150', label: `合同完工日期`, prop: 'progressFinishTime', type: 'date', visible: true },
	{ key: 5, width: '150', label: `实际开工日期`, prop: 'progressStartTime', type: 'date', visible: true },
	{ key: 6, width: '150', label: `实际撤场日期`, prop: 'progressEndTime', type: 'date', visible: true },
	{ key: 7, width: '150', label: `验收日期`, prop: 'progressCheckTime', type: 'date', visible: true },
	{ key: 8, width: '150', label: `审计日期`, prop: 'progressAuditTime', type: 'date', visible: true },
	{ key: 9, width: '150', label: `尾款到期日期`, prop: 'progressCashTime', type: 'date', visible: true },
	{ key: 10, width: '150', label: `保质期到期日期`, prop: 'progressWarrantyTime', type: 'date', visible: true }
])
const total = ref(0)
const dataList = ref([])
const queryData = reactive({
	createUserCode: route.query.createUserCode
})
const search = () => {
	selectProject(queryData).then((res) => {
		dataList.value = res
	})
}
search()
const address = ref()
const reset = () => {
	for (let item in queryData) {
		queryData[item] = ''
	}

	address.value[0]()
	search()
}
// 跳转到项目列表
const linkToProject = (row) => {
	router.push({
		path: '/question/questionAdd',
		query: { id: row.id }
	})
}
// 跳转到客户列表
const linkToCustomer = (row) => {
	router.push({
		path: '/question/questionAdd',
		query: { id: row.id }
	})
}
// 跳转到合同列表
const linkToHe = (row) => {
	router.push({
		path: '/question/questionAdd',
		query: { id: row.id }
	})
}
const toDetail = (id) => {
	router.push({
		path: '/question/questionDetail',
		query: { id: id }
	})
}
const toEdit = (id) => {
	router.push({
		path: '/question/questionEdit',
		query: { id: id }
	})
}
</script>
<style lang="scss" scoped>
.left-label {
	color: #33b6fe;
	height: 24px;
	line-height: 24px;
	position: relative;
	top: 1px;
	margin-right: 10px;
	display: inline-block;
	min-width: 80px;
}
:deep(.el-table__header) {
	background-color: #2f3f56;
}

.row3 {
	border-bottom: 1px rgba(240, 240, 240, 1) solid;
	padding: 5px 0 10px 0;
}
</style>
